<script>
import { defineComponent } from "vue"
import Layout from "@/views/layout/Layout.vue"
import SideArea from "@/views/home/components/sideArea.vue"
import Carousel from "@/views/home/components/carousel.vue"
import Account from "@/views/home/components/account.vue"
import { getAllProductApi } from "@/api/items/items"
export default defineComponent({
  components: { Account, Carousel, SideArea, Layout }
})
const search = () => {
  getAllProductApi()
    .then((res) => {
      console.log(res)
    })
    .catch((err) => {
      console.log(err)
    })
}
</script>

<template>
  <Layout>
    <SideArea />
    <Carousel />
    <Account />
    <el-divider id="separator" />
    <div id="recommend">
      <div id="recommendContent">
        <h3 id="recommendHead" style="margin-left: 40px; margin-top: 10px">
          <el-text type="warning" size="large">猜你喜欢</el-text>
          <el-image src="/src/assets/images/推荐.png" style="width: 64px; height: 20px; margin: 4px 0 0 6px" />
        </h3>
        <div style="margin-top: 2ex">
          <div class="container">
            <div class="box">
              <div class="img-box">
                <img src="https://pet-store-csu0218.oss-cn-beijing.aliyuncs.com/images/cat.jpg" alt="" />
              </div>
              <div class="text-box">
                <div>
                  <h2>家养小猫</h2>
                  <p>让人萌化了的小猫咪,性格温顺亲和。长相甜美可爱。是您家里的不可或缺的成员之一。</p>
                </div>
              </div>
            </div>
            <div class="box">
              <div class="img-box">
                <img src="https://pet-store-csu0218.oss-cn-beijing.aliyuncs.com/images/idog3.JPG" alt="" />
              </div>
              <div class="text-box">
                <div>
                  <h2>柯基犬</h2>
                  <p>小柯基犬，性格软萌、粘人，谁会拒绝一个下班会捣鼓着小短腿向你奔跑来的小可爱呢？</p>
                </div>
              </div>
            </div>
            <div class="box">
              <div class="img-box">
                <img src="https://pet-store-csu0218.oss-cn-beijing.aliyuncs.com/images/idog2.JPG " alt="" />
              </div>
              <div class="text-box">
                <div>
                  <h2>贵族犬</h2>
                  <p>生来就有些小傲娇的贵族犬，时而高贵，时而幽默，是您生活中另一个小公主！</p>
                </div>
              </div>
            </div>
            <div class="box">
              <div class="img-box">
                <img src="https://pet-store-csu0218.oss-cn-beijing.aliyuncs.com/images/icat8.JPG" alt="" />
              </div>
              <div class="text-box">
                <div>
                  <h2>蓝眼猫</h2>
                  <p>在它眼里有着星辰大海，看着它，不自觉沉陷其中，是您生活中的一个新希望！</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </Layout>
</template>

<style scoped>
#recommendContent {
  border: 1px solid #fff;
  display: inline-block;
}
#recommend {
  margin-top: 40px;
  margin-left: 44px;
  margin-bottom: 5em;
  border: 1px solid #fff;
  border-radius: 20px;
  display: flex;
  backdrop-filter: blur(10px);
}
#img {
  width: 384px;
  height: 216px;
  margin-bottom: 5ex;

  padding: 0px;
  border: 1px solid;
  /* 设置相对位置，只有将外层元素设置相对位置，子元素设置绝对位置，才能将子元素放置在父元素内部的特定位置 */
  position: relative;
}
#img > .lleft {
  width: 23px;
  height: 40px;
  /* 设置子元素绝对位置 */
  position: absolute;
  left: 0px;
  top: 48%;
}
#img > .rright {
  width: 28px;
  height: 42px;
  position: absolute;
  right: -15px;
  top: 48%;
}
#img > .lleft:hover {
  cursor: pointer;
}
#img > .rright:hover {
  cursor: pointer;
}
#topSellingImg {
  width: 384px;
  height: 216px;
  margin-bottom: 5ex;

  padding: 0px;
  border: 1px solid;
  /* 设置相对位置，只有将外层元素设置相对位置，子元素设置绝对位置，才能将子元素放置在父元素内部的特定位置 */
  position: relative;
}
#topSellingImg > .left {
  width: 23px;
  height: 40px;
  /* 设置子元素绝对位置 */
  position: absolute;
  left: 0px;
  top: 48%;
}
#topSellingImg > .left:hover {
  cursor: pointer;
}
#topSellingImg > .right {
  width: 28px;
  height: 42px;
  position: absolute;
  right: -15px;
  top: 48%;
}
#topSellingImg > .right:hover {
  cursor: pointer;
}
#separator {
  clear:both;
}
.container {
  /* 相对定位 */
  position: relative;
  /* 弹性布局 横向排列 允许换行 */
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.container .box {
  margin-left: 40px;
  position: relative;
  width: 275px;
  height: 275px;
  /* 溢出隐藏 */
  overflow: hidden;
  /* 动画过渡 */
  transition: 0.5s;
}
/* 鼠标移入，盒子变大 */
.container .box:hover {
  transform: scale(1.25);
  box-shadow: 0 25px 40px rgba(0, 0, 0, 0.5);
  z-index: 1;
  cursor: pointer;
}
.container .box .img-box {
  /* 绝对定位 */
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
/* 渐变遮罩（黑色——透明） 默认隐藏 */
.container .box .img-box::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, #222, transparent);
  z-index: 1;
  opacity: 0;
  transition: 0.5s;
}
/* 鼠标移入，渐变遮罩显示 */
.container .box:hover .img-box::before {
  opacity: 1;
}
.container .box .img-box img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  /* 保持原有尺寸比例，裁切长边 */
  object-fit: cover;
}
.container .box .text-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  /* 弹性布局 元素位于容器的结尾 */
  display: flex;
  align-items: flex-end;
  color: #fff;
  z-index: 2;
}
.container .box .text-box h2 {
  font-size: 20px;
  margin-bottom: 10px;
  /* 默认移出可视范围 */
  transform: translateY(200px);
  transition: 0.5s;
}
.container .box:hover .text-box h2 {
  /* 鼠标移入，移入可视范围 */
  transform: translateY(0);
  /* 设置动画延迟时间 */
  transition-delay: 0.3s;
}
.container .box .text-box p {
  font-size: 13px;
  line-height: 20px;
  /* 默认移出可视范围 */
  transform: translateY(200px);
  transition: 0.5s;
}
.container .box:hover .text-box p {
  /* 鼠标移入，移入可视范围 */
  transform: translateY(0);
  /* 设置动画延迟时间 */
  transition-delay: 0.4s;
}
</style>
